<?php


namespace app\models\user;


use think\Model;

class AdminUserModel extends Model
{
    protected $password = '$2y$10$IrJzWaFDNhIpZmyl7LfrduErLJ1S1cELibGz6OOJmbxk3XgEXXaOS';

    protected $name = 'admin_user';

    protected $autoWriteTimestamp = 'datetime';

    // 定义全局的查询范围
//    protected $globalScope = ['status'];
//
//    public function scopeStatus($query)
//    {
//        $query->where('status', 0);
//    }

    public function getPasswordTextAttr($value)
    {
        return $this->password;
    }

    public function role()
    {
        return $this->hasOne(AdminRoleModel::class, 'id', 'role_id')->bind(['role_name'=>'role_name']);
    }

    public function department()
    {
        return $this->hasOne(DepartmentModel::class, 'id', 'department_id')->bind(['department_name' => 'name']);
    }
}